//
//  MTRedpackModel.swift
//  MT
//
//  Created by ooops on 2019/12/22.
//  Copyright © 2019 张强. All rights reserved.
//

import Foundation
import ObjectMapper

//红包状态0可领取1已过期2已领取完3已领取过红包，510不属于该俱乐部）
enum MTOpenRedpackStatus: Int {
    /// 普通状态 - 未打开过 / 未过期
    case normal = 200
    /// 红包已经失效
    case invalid = 1
    /// 红包金额已经领完毕
    case clearance = 2
    /// 已领取过红包
    case opened = 3
    /// 领取失败
    case failed = 4
    /// 自己发的红包 - 等待好友领取 - 只在个人红包出现的状态
    case owner = 5
    /// 不属于该俱乐部
    case unonwer = 510
    /// 未知状态
    case unkonw = 1000
}


class MTRedpackModel: Mappable {
    
    var code: Int?
    var message: String?
    var success: Bool?
    var timestamp: TimeInterval?
    var result: [String : Any]?
    
    required init?(map: Map) {
        
    }
    
    open func mapping(map: Map) {
        result        <- map["result"]
        message       <- map["message"]
        success       <- map["success"]
        timestamp     <- map["timestamp"]
        code          <- map["code"]
    }
    
}

// MARK: - 领取红包模型

class MTOpenRedpackModel: Mappable {
    
    var code: Int?
    var message: String?
    var success: Bool?
    var timestamp: TimeInterval?
    var result: MTOpenRedpackResultModel?
    /// 红包类型 1 - 单人对单人, 2 - 群红包
    var sendType: Int = -1
    
    required init?(map: Map) {
        
    }
    
    open func mapping(map: Map) {
        result        <- map["result"]
        message       <- map["message"]
        success       <- map["success"]
        timestamp     <- map["timestamp"]
        code          <- map["code"]
    }
    
}

class MTOpenRedpackResultModel: Mappable {
    
    /// 红包状态
    var status: MTOpenRedpackStatus? = .unkonw
    /// 领取红包那一刻, 所有已经领取过红包的人的列表数据
    var lists: [MTOpenRedpackResultListModel]?
    /// 自己领取到的红包金额
    var pullMoney: Int?
    /// 红包id
    var sendId: Int?
    /// 红包发送者昵称
    var nickname: String?
    /// 红包数量
    var num: Int?
    /// 已领取数量
    var outNum: Int?
    /// 红包发送者的头像
    var sendUserHeadHref: String?
    /// 红包发送者的名字
    var sendUserNickname: String?
    /// 红包总金额
    var money: Int?
    /// 红包备注
    var remark: String?
    
    required init?(map: Map) {
        
    }
    
    open func mapping(map: Map) {
        status        <- map["status"]
        lists       <- map["lists"]
        pullMoney       <- map["pullMoney"]
        sendId          <- map["sendId"]
        nickname      <- map["nickname"]
        pullMoney     <- map["pullMoney"]
        num          <- map["num"]
        outNum          <- map["outNum"]
        sendUserNickname <- map["sendUserNickname"]
        sendUserHeadHref <- map["sendUserHeadHref"]
        money <- map["money"]
        remark <- map["remark"]
    }
    
}

class MTOpenRedpackResultListModel: Mappable {
    /// 领取记录id
    var pullUserId: Int?
    /// 红包领取者昵称
    var nickname: String?
    /// 发出者id
    var sendId: Int?
    /// 领取金额
    var pullMoney: Int? = 0
    /// 领取者头像
    var headHref: String?
    
    required init?(map: Map) {
        
    }
    
    open func mapping(map: Map) {
        pullUserId        <- map["pullUserId"]
        nickname       <- map["nickname"]
        sendId       <- map["sendId"]
        pullMoney     <- map["pullMoney"]
        headHref          <- map["headHref"]
    }
    
}

